package life;

import java.util.*;

// 追踪源码
public class ArrayListDemo {
    public static void main(String[] args)  {


//        List<Object> list = new ArrayList<>(10);
//        List<Object> list2 = new ArrayList<>();
//        System.out.println(list.size());
//        list.add(1);
//        list.add(1);
//        new HashSet<>().add(1);
//        TreeMap<Object, Object> objectObjectTreeMap = new TreeMap<>();
//        objectObjectTreeMap.put("11",1);
//        objectObjectTreeMap.put("13",3);
//        objectObjectTreeMap.put("12",2);
//        LinkedHashMap<Object, Object> objectObjectLinkedHashMap = new LinkedHashMap<>();
//
//        System.out.println(objectObjectTreeMap);
//        Stack<Object> objects = new Stack<>();
//        Queue<Integer> queue = new ArrayDeque<>();


//        当Integer大于默认的[-128,127]的时候就会new一个新对象

//        Integer i1 = 100;
//        Integer i2 = 100;
//        Integer i3 = 127;
//        Integer i4 = 127;
//        Integer i5 = 200;
//        Integer i6 = 200;
//        System.out.println(i1 == i2);
//        System.out.println(i3 == i4);
//        System.out.println(i5 == i6);

        Demo demo1 = new Demo("11");
        Demo demo2 = new Demo("11");
        System.out.println(demo1.equals(demo2));

        String s1 = "Hello";
        String s2 = "Hello";
        String s3 = new String("Hello");
        System.out.println("s1和s2 引用地址是否相同：" + (s1 == s2));
        System.out.println("s1和s2 值是否相同：" + s1.equals(s2));
        System.out.println("s1和s3 引用地址是否相同：" + (s1 == s3));
        System.out.println("s1和s3 值是否相同：" + s1.equals(s3));
        long ans[][] = new long[2][5];//01234->aeiou
        Arrays.fill(ans[0], 1);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 5; j++) {
                System.out.print(ans[i][j] + "\t");
            }
            System.out.println();
        }

        HashMap<Object, Object> map = new HashMap<>();
        map.put(1, 1);
        map.put(1, 2);
        System.out.println(map);
        String s = "";
        String s12=null;
//        System.out.println(s12.length());
        System.out.println();
//        System.out.println(s12.isEmpty());  报错


        D d = new D();
        d.test();
    }


}


class Demo {
    public String name;

    Demo(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Demo demo = (Demo) o;
        return Objects.equals(name, demo.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
